#ifndef __coll_CollisionControl_Header_File__
#define __coll_CollisionControl_Header_File__

#include "common.h"
#include "core/coll/AABB.h"
#include "core/coll/ICollision.h"
#include "core/coll/IColStr.h"
#include "core/scgr/TreeNode.h"

namespace core
{

	namespace coll
	{
		/**
		 * Class providing collision detection. This class provides
		 * detection of collision on list of ICollision implementation
		 * objects.
		 */
		class CollisionControl 
		{
		public:
			/**
			 * List of ICollision implementation objects type
			 */
			typedef std::vector<ICollision*> CollisionList;

			/**
			 * Iterator on a list of ICollision implementation objects type
			 */
			typedef CollisionList::iterator CLIterator;

			/**
			 * Constant iterator on a list of ICollision implementation objects type
			 */
			typedef CollisionList::const_iterator CLConstIterator;



			/**
			 * Creates new collision control object.
			 *
			 * @param colList_ list of an ICollision implementation objects.
			 */
		  CollisionControl(const CollisionList& colList_)
				: colList(colList_)
			{}

			/**
			 * Does collision test of subject on all items in colList 
			 * (passed in constructor).
			 *
			 * @param subject Object to be tested against all items in colList
			 * @return Pointer to ICollision implementation, that collides with 
			 * subject or NULL if collision doesn't happend.
			 */
			ICollision* collide(const IColStr* subject) const;
		private:
			/**
			 * List of all items to be tested for collision.
			 */
			const CollisionList& colList;

			/**
			 * Test collision of two AABBs
			 *
			 * @param b1 First AABB collision object.
			 * @param b2 Second AABB collision object.
			 *
			 * @return True if b1 intersects with b2, otherwise returns Flase.
			 */
			bool aabbVsAabb(const AABB3<f32>* b1, const AABB3<f32>* b2) const;
		};
	}

}



#endif // __coll_CollisionControl_Header_File__
